const install = (Vue, vm) => {
	// 获取首页数据
	let getHomeData = (params = {}) => vm.$u.get('/api/index', params);

	// 登录
	let getInfo = (params = {}) => vm.$u.post("/api/auth/login", params);

	// 用户详情
	let getUser = (params = {}) => vm.$u.get("/api/user");

	// 用户注册
	let register = (params = {}) => vm.$u.post("/api/auth/register", params);

	// 获取阿里云OSS Token，用于前端直传文件使用
	let getOssToken = (params = {}) => vm.$u.get("/api/auth/oss/token");

	// 更新用户信息
	let upadateUser = (params = {}) => vm.$u.put("/api/user", params);

	// 更新头像
	let upadateAvater = (params = {}) => vm.$u.post("/api/user/avatar", params);

	// 商品列表
	let goodsList = (params = {}) => vm.$u.get("/api/goods", params);

	// 加入购物车
	let addCart = (params = {}) => vm.$u.post("/api/carts", params);

	// 购物车列表
	let CartList = (params = {}) => vm.$u.get("/api/carts?include=goods");

	// 购物车改变选中
	let checked = (params = {}) => vm.$u.patch("/api/carts/checked",params);

	// 订单预览
	let orderPreview = (params = {}) => vm.$u.get("/api/orders/preview");
	
	// 退出登录
	let exit = (params = {}) => vm.$u.post("/api/auth/logout");

	// 添加地址
	let addAddress = (params = {}) => vm.$u.post("/api/address", params);
	
	// 地址列表
	let addressList = (params = {}) => vm.$u.get("/api/address");
	
	// 我的收藏
	let collectList = (params = {}) => vm.$u.get("/api/collects");


	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		getHomeData,
		getInfo,
		getUser,
		getOssToken,
		register,
		upadateUser,
		exit,
		upadateAvater,
		addCart,
		goodsList,
		CartList,
		checked,
		orderPreview,
		addAddress,
		addressList,
		collectList
	};
}

export default {
	install
}
